package com.lvc.fotolivro.client;

import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.util.EventHandler;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.events.DropEvent;
import com.smartgwt.client.widgets.events.DropHandler;
import com.smartgwt.client.widgets.events.ShowContextMenuEvent;
import com.smartgwt.client.widgets.events.ShowContextMenuHandler;

/**
 * Esta classe representa uma página do fotolivro.
 * 
 * @author Larissa Nepomuceno Costa
 * @version 1
 * @since 08/10/2012
 */
public class Page extends Canvas {
	public Page() {
		setWidth(300);
		setHeight(400);
//		setShowEdges(true);
//		setEdgeSize(1);
		setOverflow(Overflow.HIDDEN);
		setCanAcceptDrop(true);
		setBackgroundColor("#000000");
		addShowContextMenuHandler(new ShowContextMenuHandler() {
			public void onShowContextMenu(ShowContextMenuEvent event) {
				event.cancel();
			}
		});
//		addDropOverHandler(new DropOverHandler() {
//			public void onDropOver(DropOverEvent event) {
//				setBackgroundColor("#f68a8a");
//			}
//		});
//		addDropOutHandler(new DropOutHandler() {
//			public void onDropOut(DropOutEvent event) {
//				setBackgroundColor("#ffff80");
//			}
//		});
		addDropHandler(new DropHandler() {
			public void onDrop(DropEvent event) {
				String caminho = "fotos"+(((Img) EventHandler.getDragTarget()).getSrc()).split("fotos")[1];
				addChild(new MyDropPhoto(caminho, getOffsetX()-15, getOffsetY()-15));
//	addChild(new MyDropPhoto(a,getOffsetX() - 15 - getEdgeSize(),getOffsetY() - 15 - getEdgeSize()));
			}
		});
	}
	
	public void setColor(String cor){
		setBackgroundColor(cor);
	}
	
	public void setSize(String largura, String altura){
		setWidth(largura);
		setHeight(altura);
	}
	
}